package com.yang.SpringTest.annotation.scopeLearn;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * <p>ScopeDemoTest 测试类</p>
 *
 * @author By: chengxuyuanshitang
 * Package com.yang.SpringTest.annotation.scopeLearn
 * Ceate Time 2024-04-09 17:10
 */
@Slf4j
public class ScopeDemoTest {
    public static void main (String[] args) {

        log.info ("========== 创建IOC容器开始==========");
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (ScopeDemoConfig.class);
        log.info ("==========创建IOC容器结束==========");


        log.info ("==========IOC容器中获取Bean开始==========");

        ScopeSingletonDemo scopeSingletonDemo1 = context.getBean (ScopeSingletonDemo.class);
        ScopeSingletonDemo scopeSingletonDemo2 = context.getBean (ScopeSingletonDemo.class);

        log.info ("**************** scopeSingletonDemo1是否等于scopeSingletonDemo2 : {}", (scopeSingletonDemo1 == scopeSingletonDemo2));

        ScopePrototypeDemo scopePrototypeDemo1 = context.getBean (ScopePrototypeDemo.class);
        ScopePrototypeDemo scopePrototypeDemo2 = context.getBean (ScopePrototypeDemo.class);
        log.info ("**************** scopePrototypeDemo1是否等于scopePrototypeDemo2 : {}", (scopePrototypeDemo1 == scopePrototypeDemo2));

        log.info ("==========从IOC容器中获取Bean结束==========");
        context.close ();
    }
}

